from sklearn.model_selection import train_test_split
import numpy as np


def fractionaldata(result_x, result_y):
    X_train, X_test, y_train, y_test = train_test_split(result_x, result_y, test_size=0.2,
                                                        random_state=result_x.shape[0])
    X_data_1_test, y_data_1_test = X_test, y_test
    X_data_1_train, y_data_1_train = X_train, y_train

    X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.25,
                                                        random_state=result_x.shape[0])
    X_data_2_test, y_data_2_test = X_test, y_test
    X_data_2_train = np.concatenate((X_train, X_data_1_test), axis=0)
    y_data_2_train = np.concatenate((y_train, y_data_1_test), axis=0)

    X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=(1 / 3),
                                                        random_state=result_x.shape[0])
    X_data_3_test, y_data_3_test = X_test, y_test
    X_data_3_train = np.concatenate((X_train, X_data_1_test, X_data_2_test), axis=0)
    y_data_3_train = np.concatenate((y_train, y_data_1_test, y_data_2_test), axis=0)

    X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.5,
                                                        random_state=result_x.shape[0])
    X_data_4_test, y_data_4_test = X_test, y_test
    X_data_4_train = np.concatenate((X_train, X_data_1_test, X_data_2_test, X_data_3_test), axis=0)
    y_data_4_train = np.concatenate((y_train, y_data_1_test, y_data_2_test, y_data_3_test), axis=0)

    X_data_5_test, y_data_5_test = X_train, y_train
    X_data_5_train = np.concatenate((X_data_4_test, X_data_1_test, X_data_2_test, X_data_3_test), axis=0)
    y_data_5_train = np.concatenate((y_data_4_test, y_data_1_test, y_data_2_test, y_data_3_test), axis=0)

    return ((X_data_1_train, X_data_1_test, y_data_1_train, y_data_1_test),
            (X_data_2_train, X_data_2_test, y_data_2_train, y_data_2_test),
            (X_data_3_train, X_data_3_test, y_data_3_train, y_data_3_test),
            (X_data_4_train, X_data_4_test, y_data_4_train, y_data_4_test),
            (X_data_5_train, X_data_5_test, y_data_5_train, y_data_5_test),
            )
